package nl.zuiderfestival.raydance.view.particle;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

public class Particle {
	private int x;
	private int y;
	private int size;
	private int initialLife;
	private int life;
	private Color color;

	public Particle(int x, int y, int size, int life, Color c){
		this.x = x;
		this.y = y;
		this.size = size;
		this.initialLife = life;
		this.life = life;
		this.color = c;
	}

	public boolean update(){
		life--;
		if(life <= 0)
			return true;
		return false;
	}


	public void render(Graphics g){
		Graphics2D g2d = (Graphics2D) g.create();
		
		double life = (double) this.life;
		double initialLife = (double) this.initialLife;
		
		double alpha = life/initialLife*255.0;
		g2d.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), (int)alpha));
		
		g2d.fillOval(x-(size/2), y-(size/2), size, size);

		g2d.dispose();
	}

}
